import re
types = ("int64","int32","string","bool","bytes")
with open("pythonProto.txt", "w", encoding="utf-8") as wf:
    wf.write("")
with open("douyinProto.txt","r+",encoding="utf-8") as f:
    for i in f.readlines():
        choose = 1
        text = i
        print(text)
        try:
            res = re.findall("e\.(\w*)", text)[0]
            if res == "int64String":
                res = "int64"
        except :
            res = "//repeated"
        for ty in types:
            if res == ty:
                choose = 0
        if choose:
            res = "//repeated"
        res += " " + re.findall('"(\w*)', text)[0]
        res += " = " + re.match('\d+', text).group() + ";\n"
        with open("pythonProto.txt","a",encoding="utf-8") as wf:
            wf.write(res)

